﻿
@section scripts{
    <script type="text/javascript">
        var bootstrap = function ($, ibpm) {
            "use strict";
            var page = {
                init: function () {
                    $("#En_add").on('click', page.AddAct);
                    $("#En_edit").on('click', page.EditAct);
                    $("#En_delete").on('click', page.DelAct);
                    $("#btn_Search").on('click', function () {
                        page.search();
                    });
                    $('#btn_Refresh').on('click', function () {
                        location.reload();
                    });
                    page.initGrid();
                    page.bind();
                },
                bind: function () {

                },
                initGrid: function () {
                    $('#gridtable').jfGrid({
                        url: top.$.rootUrl + '/Org/Position/GetTreeList',
                        headData: [
                            { label: '简称', name: 'ShortName', index: "ShortName", width: 160, align: 'left' },
                            { label: '岗位名称', name: 'FullName', index: "FullName", width: 220, align: 'left' },
                            { label: '性质', name: 'Nature', width: 320, align: 'center' },
                            {
                                label: "", name: "btn", width: 100, align: "center",
                                formatter: function (cellvalue) {
                                    return "";
                                }
                            }
                        ],
                        mainId: 'PositionId',
                        sidx: 'PositionId',    //排序
                        isPage: false,
                        rows: 9900,
                    }).jfGridSet('reload'); //默认带数据
                },
                AddAct: function () {
                    ibpm.httpAsyncPost(top.$.rootUrl + "/Org/Position/NodeAdd", {}, function (json) {
                        $("#NodeSave").ibpm_SetFormData(json.data);
                        $('#AddNode').modal("show");
                        $('#F_CompanyCategory').ibpm_selectSet(json.data.CompanyCategory);
                    });
                },
                EditAct: function () {
                    var keyValue = $('#gridtable').jfGridValue('PositionId');
                    if (ibpm.checkrow(keyValue)) {
                        ibpm.postForm(top.$.rootUrl + "/Org/Position/NodeEdit", { keyValue: keyValue }, function (json) {
                            $("#NodeSave").ibpm_SetFormData(json.data);
                            $('#AddNode').modal("show");
                            $('#F_CompanyCategory').ibpm_selectSet(json.data.CompanyCategory);
                            $('#ParentName').val(json.data.ParentName);
                            $('#FoundedTime').val(ibpm.formatDate(json.data.FoundedTime, "yyyy-MM-dd"));
                        });
                    }
                },
                DelAct: function () {
                    var keyValue = $('#gridtable').jfGridValue('PositionId');
                    if (ibpm.checkrow(keyValue)) {
                        ibpm.layerConfirm('是否确认删除该项！', function (res) {
                            if (res) {
                                ibpm.deleteForm(top.$.rootUrl + '/Org/Position/NodeDelete', { keyValue: keyValue }, function () {
                                    page.search();
                                });
                            }
                        });
                    }
                },
                search: function (param) {
                    param = param || {};
                    param.keyword = $('#txt_Keyword').val();
                    $('#gridtable').jfGridSet('reload', param);
                }
            };
            page.init();
        };
        function EndReq(data) {
            $('#AddNode').modal("hide");
            $('#gridtable').jfGridSet('reload');
        };
    </script>
}

<div class="row">
    <div class="step-pane">
        <div class="row">
            <div class="col-md-5">
                <div class="input-group">
                    <input id="txt_Keyword" type="text" class="form-control-sm form-control" placeholder="请输入要查询的关键字" />
                    <span id="btn_Search" class="input-group-addon btn btn-primary"><i class="fa fa-search"></i>&nbsp;搜索</span>
                    <span id="btn_Refresh" class="input-group-addon btn btn-info"><i class="fa fa-refresh"></i>&nbsp;刷新</span>
                </div>
            </div>
            <div class="col-md-7">
                <div class="btn-group btn-group-sm" style="float:right;">
                    <a id="En_add" class="btn btn-default"><i class="fa fa-plus"></i>&nbsp;新增岗位</a>
                    <a id="En_edit" class="btn btn-default"><i class="fa fa-pencil-square-o"></i>&nbsp;编辑岗位</a>
                    <a id="En_delete" class="btn btn-default"><i class="fa fa-trash-o"></i>&nbsp;删除岗位</a>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row">
    <div class="step-pane">
        <div id="gridtable" style="margin-top:10px;"></div>
    </div>
</div>

<div class="modal fade" id="AddNode" tabindex="-11" role="dialog" aria-labelledby="AddNode" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content animated bounceInRight">
            <div class="modal-header">
                <h3 class="modal-title">岗位基础信息</h3>
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
                </button>
            </div>
            <form action="/Org/Position/NodeSave" id="NodeSave" method="post" onsubmit="return FormSaveReport('NodeSave');">
                <div class="modal-body">
                    <input type="hidden" id="PositionId" name="PositionId" value="" />
                    <input type="hidden" id="ModifyUserId" name="ModifyUserId" value="" />
                    <div class="row">
                        <div class="form-group col-sm-4">
                            <label>简称</label>
                            <input class="form-control single-line" id="ShortName" name="ShortName" placeholder="简称" type="text" value="">
                        </div>
                        <div class="form-group col-sm-8">
                            <label>岗位名称</label>
                            <input class="form-control single-line" id="FullName" name="FullName" placeholder="岗位名称" type="text" value="">
                        </div>
                    </div>
                    <div class="block">
                        <div class="form-group">
                            <label>岗位性质</label>
                            <input class="form-control single-line" id="Nature" name="Nature" placeholder="岗位性质" type="text" value="">
                        </div>
                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
                    <input type="submit" value="Save" class="btn btn-success">
                </div>
            </form>
        </div>
    </div>
</div>
